#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : gtmsAutoTestProject 
@File    : table_api.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/4/26 11:29 
@Describe: 台位相关操作接口
"""
from APIs.posApi.base_pos_api import BasePosApi


class TableApi(BasePosApi):

    def __init__(self, brandCode, environment):
        super().__init__(brandCode, environment)

    def table_list(self, operate=''):
        """
        台位列表
        :param operate: 台位操作: 1-换台, 2-并台, 3-搭台, 4-拆台, 5-退台, 6-锁台, 7-解锁 0-空台
        :return: response
        """
        payload = '{"operate":"' + operate + '"}'
        response = self.http_requests('table/list', payload)
        return response

    def table_repeal(self, table_code):
        """
        台位退台
        :param table_code: 台位编码
        :return: response
        """
        payload = '{"reasonCode":"back-01","tableCode":"' + table_code + '"}'
        response = self.http_requests('table/repeal', payload)
        return response

    def table_open(self, tableCode, peopleNum='5'):
        """
        台位开台
        :param tableCode: 台位号
        :param peopleNum: 用餐人数
        :return: response
        """
        payload = '{"tableCode":"' + tableCode + '","peopleNum":"' + peopleNum + '"}'
        response = self.http_requests('table/open', payload)
        return response


if __name__ == '__main__':
    from Comm.tools.toolsControl import ToolsHandler

    test = TableApi('823882', 'sit')
    table_list = test.table_list('7')
